package com.joysuch.wwyt.bp.entity.contractor;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDate;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2020/7/8 15:59
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_contractor")
@SQLDelete(sql = "update wwyt_bp_contractor set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_contractor set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@Proxy(lazy = false)
@TableName("wwyt_bp_contractor")
public class BpContractor {

    @ApiModelProperty("id-修改时传值")
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    @NotNull(message = "承包商单位名称不能为空")
    @ApiModelProperty("承包商单位名称")
    private String companyName;
    @ApiModelProperty("编号-新增不用传")
    private String code;
    @ApiModelProperty("承包商单位地址")
    private String companyAddress;
    @ApiModelProperty("承包商类别")
    private String contractorType;
    @ApiModelProperty("承包商业务类型json")
    private String businessType;
    @ApiModelProperty("公司法人")
    private String companyLegalPerson;
    @ApiModelProperty("统一社会信用代码")
    private String unifiedSocialCreditCode;
    @ApiModelProperty("承包商电话")
    private String contractorTel;
    @ApiModelProperty("邮箱")
    private String mail;
    @ApiModelProperty("安全负责人")
    private String safetyDirector;
    @ApiModelProperty("安全负责人电话")
    private String safetyDirectorTel;
    @ApiModelProperty("公司介绍")
    private String companyIntroduction;
    @ApiModelProperty("经营范围")
    private String businessScope;
    @ApiModelProperty("责任书签订日期")
    private LocalDate dutyScriptSignDate;
    @ApiModelProperty("责任书到期日期")
    private LocalDate dutyScriptExpireDate;
    @ApiModelProperty("责任书附件json")
    private String dutyScriptAttachment;
    @ApiModelProperty("数据状态字段: 0 无效; 1 有效")
    private Integer state;
    @ApiModelProperty("责任书到期是否已提醒: 0 否; 1 是")
    private Integer dutyScriptRemindOrNot = 0;

    @Transient
    @ApiModelProperty("责任书是否有效")
    private String dutyScriptEffectiveOrNot = "是";
    @Transient
    @ApiModelProperty("证书是否有效")
    private String certEffectiveOrNot = "是";

    //外部链接URL
    private String refUrl;

    @ApiModelProperty("雪花id")
    private String uniqueId;

    @ApiModelProperty("单位性质")
    private String unitNature;


    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;
    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    @JsonIgnore
    private java.time.LocalDateTime createTime;
    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    @JsonIgnore
    private Long updateBy;
    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    @JsonIgnore
    private java.time.LocalDateTime updateTime;
    @ApiModelProperty("租户")
    @JsonIgnore
    private Long tenentId;
    @ApiModelProperty("组织机构代码")
    @JsonIgnore
    private String orgCode;
    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
    //管理部门
    @DataPermissionField(sqlColumn = "responsible_dept")
    private Long responsibleDept;

    //是否同步
    @ApiModelProperty("是否同步")
    private Boolean locateSync;
}
